Consider the Hock-Schittkowski problem, which is defined as follows:

  • Decision variables: $x_1,x_2,x_3,x_4$
  • Objective value: $z$

Formulation:

$$ \left.\begin{array}{rrcl} \min & z = x_1x_4(x_1 + x_2 + x_3) + x_3 \\ \text {s.t.:} & & & \\ \text{(1)} & x_1x_2x_3x_4 \geq 25\\ \text{(2)} & x^2_1 + x^2_2 +x^2_3 +x^2_4 = 40\\ \text{(3)} & 1 \leq x_1,x_2,x_3,x_4 \leq 5 \end{array}\right\} $$

What is the (rounded) optimal solution?


In [5]:
using JuMP
using NLopt
m = Model(solver=NLoptSolver(algorithm=:LD_SLSQP))

# Adding Variables
@variable(m, 1 <= x[1:4] <= 5)

print(m)
# Adding nonlinear constraints
@NLconstraint(m, x[1] * x[2] * x[3] * x[4] >= 25)
@NLconstraint(m, x[1]^2 * x[2]^2 * x[3]^2 * x[4]^2 == 40)

# Adding nonlinear objective
@NLobjective(m, Min, x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3])

solve(m)


INFO: Precompiling module NLopt.
ERROR: LoadError: NLopt not properly installed. Please run Pkg.build("NLopt")
 in error(::String) at .\error.jl:21
 in include_from_node1(::String) at .\loading.jl:488
 in macro expansion; at .\none:2 [inlined]
 in anonymous at .\<missing>:?
 in eval(::Module, ::Any) at .\boot.jl:234
 in process_options(::Base.JLOptions) at .\client.jl:239
 in _start() at .\client.jl:318
while loading C:\Users\ssuman\.julia\v0.5\NLopt\src\NLopt.jl, in expression starting on line 22
LoadError: Failed to precompile NLopt to C:\Users\ssuman\.julia\lib\v0.5\NLopt.ji.
while loading In[5], in expression starting on line 2

 in compilecache(::String) at .\loading.jl:593
 in require(::Symbol) at .\loading.jl:422

In [ ]: